package toolfunc

import (
// "fmt"
)

func BinaryFind(arrslice []int64, findvalue int64) int {
	var low int = 0
	var height int = len(arrslice) - 1
	for {
		if low <= height {
			middle := low + (height-low)/2
			var midValue = arrslice[middle]
			if midValue == findvalue {
				return middle
			} else if midValue > findvalue {
				height = middle - 1
			} else if midValue < findvalue {
				low = middle + 1
			}
		} else {
			break
		}
	}
	return -1
}
